<template>
  <div id="loginInput">
    <div class="input">
      <div style="text-align:center;padding-top:10px">
        <router-link to="/">
          <svg class="login_logo" aria-hidden="true">
            <use xlink:href="#icon-icon_xiangji"></use>
          </svg>
        </router-link>
      </div>
      <div class="admin_name">
        <Input v-model="name" prefix="ios-contact" size="large" placeholder="Enter name" clearable/>
        <p></p>
      </div>
      <div class="admin_pass">
        <Input
          clearable
          prefix="ios-lock"
          size="large"
          type="password"
          placeholder="Enter password"
          v-model="password"
        />
      </div>
      <div style="margin-top: 25px;">
        <Slider class v-model="value1"></Slider>
      </div>
      <Button type="info" class="admin_login" size="large" @click="HanderAdminLogin">登录</Button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "LoginInput",
  data() {
    return {
      value1: 0,
      name: "",
      password: ""
    };
  },
  methods: {
    HanderAdminLogin() {
      let adminjsons = {
        adname: this.name,
        password: this.password
      };
      if (this.value1 == 100) {
        axios.post("api/adminLogin", adminjsons).then(res => {
            res = res.data;
            if (res.data) {
              this.$router.push("/Admin");
            } else {
              alert("账户名或密码错误")
            }
          }).catch(function(error) {
            alert(error);
          });
      } else {
        alert("请进行验证");
      }
    }
  }
};
</script>

<style scoped>
#loginInput {
  width: 25vw;
  background-color: rgb(248, 248, 249);
}
.input {
  width: 18vw;
  margin: 0 auto;
}
.admin_login {
  background-color: rgb(71, 203, 137);
  border-color: #fff;
  width: 100%;
  margin: 15px 0 30px 0;
}
.input div {
  margin: 10px auto;
}
p {
  line-height: 0px;
}
.login_logo {
  width: 50px;
  height: 55px;
}
</style>
